package hermesV2.services.P2P_Request;

import hermesV2.PlaceAddress;
import hermesV2.agent.AbstractProtocol;
import hermesV2.agent.Interaction;



public class P2P_ServiceProtocol extends AbstractProtocol {
   /**
	 * 
	 */
	private static final long serialVersionUID = 5338161764057772696L;

public static final String REQUEST = "REQUEST";

   public static final String RESPONSE = "RESPONSE";

   public static final String ERROR = "ERROR";

   public static final String INVOKE = "INVOKE";

      
   public static final String INTERACTION11REQUEST = "CalculateDistance";
   public static final String INTERACTION11RESPONSE = "ResponseCalculateDistance";
   public static final String INTERACTION11ERROR = "ErrorCalculateDistance";
   
   
   public static final String INTERACTION13REQUEST = "DrawMap";
   public static final String INTERACTION13RESPONSE = "ResponseDrawMap";
   public static final String INTERACTION13ERROR = "ErrorDrawMap";
   
   public static final String INTERACTION14REQUEST = "WaitSecondWinner";
   public static final String INTERACTION14RESPONSE = "ResponseWait";
   public static final String INTERACTION14ERROR = "ErrorWait";
      
   public static final String INTERACTION16REQUEST = "SecondWinner";
   public static final String INTERACTION16RESPONSE = "ResponseSecondWinner";
   public static final String INTERACTION16ERROR = "ErrorSecondWinner";
   
   
   public P2P_ServiceProtocol() {
       super("RequstServiceProtocol");
       

       {
       // #####  DRAW MAP   ####
       String[] parameterNameInteraction13Request = new String[1];
       parameterNameInteraction13Request[0] = "CoordinateSender";

       
       Class<?>[] parameterTypeInteraction13Request = new Class[1];
       parameterTypeInteraction13Request[0] = String.class;

       
       Interaction drawMap = new Interaction(INTERACTION13REQUEST,
    		   "DrawMap", REQUEST,
               parameterNameInteraction13Request,
               parameterTypeInteraction13Request);
       addInteraction(drawMap);
       
       String[] parameterNameInteraction13Response = new String[1];
       parameterNameInteraction13Response[0] = "ResponseDrawPath";

       Class<?>[] parameterTypeInteraction13Response = new Class[1];
       parameterTypeInteraction13Response[0] = String.class;
       Interaction responseDrawMap = new Interaction(INTERACTION13RESPONSE,
               "ResponseDrawMap",RESPONSE,
               parameterNameInteraction13Response,
               parameterTypeInteraction13Response);
       addInteraction(responseDrawMap);
       addResponseLink(drawMap,responseDrawMap);
       
       //Error Dynamic Call Protocol Parameter
       String[] parameterNameInteraction13Error = new String[1];
       parameterNameInteraction13Error[0] = "Error";
       Class<?>[] parameterTypeInteraction13Error = new Class[1];
       parameterTypeInteraction13Error[0] = String.class;
       Interaction errorDrawMap= new Interaction(INTERACTION13ERROR,"ErrorMessageRequest",ERROR,parameterNameInteraction13Error,parameterTypeInteraction13Error);
       addInteraction(errorDrawMap);
       addErrorLink(drawMap,errorDrawMap);
       }
       
       
       
       
     
       
    
       {
       // #####  CALCULATES DISTANCE   ####
       String[] parameterNameInteraction11Request = new String[1];
       parameterNameInteraction11Request[0] = "CoordinateSender";
       
       Class<?>[] parameterTypeInteraction11Request = new Class[1];
       parameterTypeInteraction11Request[0] = String.class;

       Interaction calculatesDistance = new Interaction(INTERACTION11REQUEST,
    		   "CalculatesDistance", REQUEST,
               parameterNameInteraction11Request,
               parameterTypeInteraction11Request);
       addInteraction(calculatesDistance);
       
       String[] parameterNameInteraction11Response = new String[1];
       parameterNameInteraction11Response[0] = "ResponseTimeDistance";
       Class<?>[] parameterTypeInteraction11Response = new Class[1];
       parameterTypeInteraction11Response[0] = Integer.class;
       Interaction responseCalculateDistance = new Interaction(INTERACTION11RESPONSE,
               "ResponseCalculatesDistance",RESPONSE,
               parameterNameInteraction11Response,
               parameterTypeInteraction11Response);
       addInteraction(responseCalculateDistance);
       addResponseLink(calculatesDistance,responseCalculateDistance);
       
       //Error Dynamic Call Protocol Parameter
       String[] parameterNameInteraction11Error = new String[1];
       parameterNameInteraction11Error[0] = "Error";
       Class<?>[] parameterTypeInteraction11Error = new Class[1];
       parameterTypeInteraction11Error[0] = String.class;
       Interaction errorCalculatesDistance= new Interaction(INTERACTION11ERROR,"ErrorCalculatesDistance",ERROR,parameterNameInteraction11Error,parameterTypeInteraction11Error);
       addInteraction(errorCalculatesDistance);
       addErrorLink(calculatesDistance,errorCalculatesDistance);
       }
       
       {
          // #####  WAIT SECOND WINNER   ####
       
       String[] parameterNameInteraction14Request = new String[3];
       parameterNameInteraction14Request[0] = "SenderPlace";
       parameterNameInteraction14Request[1] = "minimumTimeDistance";
       parameterNameInteraction14Request[2] = "nearestPeer";
       
       Class<?>[] parameterTypeInteraction14Request = new Class[3];
       parameterTypeInteraction14Request[0] = PlaceAddress.class;
       parameterTypeInteraction14Request[1] = Integer.class;
       parameterTypeInteraction14Request[2] = PlaceAddress.class;

       Interaction waitSecondWinner = new Interaction(INTERACTION14REQUEST,
    		   "WaitSecondWinner", REQUEST,
               parameterNameInteraction14Request,
               parameterTypeInteraction14Request);
       addInteraction(waitSecondWinner);
       
       String[] parameterNameInteraction14Response = new String[2];
       parameterNameInteraction14Response[0] = "Response";
       parameterNameInteraction14Response[1] = "Winner";
       Class<?>[] parameterTypeInteraction14Response = new Class[2];
       parameterTypeInteraction14Response[0] = String.class;
       parameterTypeInteraction14Response[1] = PlaceAddress.class;
       Interaction responsWaitSecondWinner = new Interaction(INTERACTION14RESPONSE,
               "ResponseWaitSecondWinner",RESPONSE,
               parameterNameInteraction14Response,
               parameterTypeInteraction14Response);
       addInteraction(responsWaitSecondWinner);
       addResponseLink(waitSecondWinner,responsWaitSecondWinner);
       
       //Error Dynamic Call Protocol Parameter
       String[] parameterNameInteraction14Error = new String[1];
       parameterNameInteraction14Error[0] = "Error";
       Class<?>[] parameterTypeInteraction14Error = new Class[1];
       parameterTypeInteraction14Error[0] = String.class;
       Interaction errorWaitSecondWinner= new Interaction(INTERACTION14ERROR,"ErrorWaitSecondWinner",ERROR,parameterNameInteraction14Error,parameterTypeInteraction14Error);
       addInteraction(errorWaitSecondWinner);
       addErrorLink(waitSecondWinner,errorWaitSecondWinner);
       }

       
       
       
       
       
       {
    	// ##### SECOND WINNER   ####
           String[] parameterNameInteraction16Request = new String[3];
           parameterNameInteraction16Request[0] = "SenderPlace";
           parameterNameInteraction16Request[1] = "minimumTimeDistance";
           parameterNameInteraction16Request[2] = "nearestPeer";
           
           Class<?>[] parameterTypeInteraction16Request = new Class[3];
           parameterTypeInteraction16Request[0] = PlaceAddress.class;
           parameterTypeInteraction16Request[1] = Integer.class;
           parameterTypeInteraction16Request[2] = PlaceAddress.class;

           Interaction secondWinner = new Interaction(INTERACTION16REQUEST,
        		   "SecondWinner", REQUEST,
                   parameterNameInteraction16Request,
                   parameterTypeInteraction16Request);
           addInteraction(secondWinner);
           
           String[] parameterNameInteraction16Response = new String[2];
           parameterNameInteraction16Response[0] = "Response";
           parameterNameInteraction16Response[1] = "Winner";
           Class<?>[] parameterTypeInteraction16Response = new Class[2];
           parameterTypeInteraction16Response[0] = String.class;
           parameterTypeInteraction16Response[1] = PlaceAddress.class;
           Interaction responsSecondWinner = new Interaction(INTERACTION16RESPONSE,
                   "ResponseSecondWinner",RESPONSE,
                   parameterNameInteraction16Response,
                   parameterTypeInteraction16Response);
           addInteraction(responsSecondWinner);
           addResponseLink(secondWinner,responsSecondWinner);
           
           //Error Dynamic Call Protocol Parameter
           String[] parameterNameInteraction16Error = new String[1];
           parameterNameInteraction16Error[0] = "Error";
           Class<?>[] parameterTypeInteraction16Error = new Class[1];
           parameterTypeInteraction16Error[0] = String.class;
           Interaction errorSecondWinner= new Interaction(INTERACTION16ERROR,"ErrorSecondWinner",ERROR,parameterNameInteraction16Error,parameterTypeInteraction16Error);
           addInteraction(errorSecondWinner);
           addErrorLink(secondWinner,errorSecondWinner);
           }
       
      
   
       
       
   }
   
}